<template>
	<section>
		<headers txt="旧密码修改密码"></headers>
		<ul class="mu20 ">
			
			<li class="bbtm md10 sz30 wallfff flexs plr30  hei100">
				<label for="pwd1" class="flex_self w25">旧密码</label>
				<input id="pwd1" v-model="pwd1" class="flex1 sz30" type="password" placeholder="输入旧密码" />
			</li>
			<li class="bbtm md10 sz30 wallfff flexs plr30  hei100">
				<label for="pwd2" class="flex_self w25">新密码</label>
				<input id="pwd2" v-model="pwd2" class="flex1 sz30" type="password" placeholder="输入新密码" />
			</li>
			<li class="bbtm md10 sz30 wallfff flexs plr30  hei100">
				<label for="pwd3" class="flex_self w25">确认密码</label>
				<input id="pwd3" v-model="pwd3" class="flex1 sz30" type="password" placeholder="再次输入新密码" />
			</li>
		</ul>
		<button class="btns mu30" type="button" @click="newpwd">重置密码</button>
	</section>
</template>

<script>
	import { Toast } from 'mint-ui';
	import { Indicator } from 'mint-ui';
	import Qs from 'qs';
	import md5 from 'js-md5';
	export default {
		data() {
			return {
				pwd1: "",
				pwd2: "",
				pwd3: ""
			}
		},
		methods: {
			
			newpwd: function () {
				let v = this;
				if(!/^\w{6,12}$/.test(v.pwd1)) {
					Toast("请输入旧密码");
				}else if(!/^\w{6,12}$/.test(v.pwd2)) {
					Toast("请输入数字、字母及下划线组成的6-12位密码");
				} else if(v.pwd2 !== v.pwd3) {
					Toast("两次输入密码不相同");
				}else{
					Indicator.open({
						text: '请求中，请稍等'
					});
					
					this.$http.post("/WorkMembers/V1.0/EditPwdByPwd", Qs.stringify({
						"MembersID": this.$store.state.MembersID,
						"PwdType": v.$route.query.types,
						"OldPwd": md5(v.pwd1),
						"Pwd": md5(v.pwd2)

					})).then((res) => {
						Indicator.close();
						Toast(res.data.Return_Mess);

					}).catch((err) => {
						Indicator.close();
						Toast(err);
					});
				}
			}
		},
		
	}
</script>

<style scoped>
	
</style>